package net.oschina.bilbodai.common.beanutil.bean.core;

import net.oschina.bilbodai.common.beanutil.bean.type.NullType;

import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @author daimao  Date: 16/6/14 Time: 上午10:45
 * @version $Id$
 */
public class CollectImplTypes {

    public static Class<?> findProperCollectImplType(Class<?> fieldType) {
        if (!fieldType.isInterface())
            return fieldType;
        if (Map.class.isAssignableFrom(fieldType))
            return LinkedHashMap.class;
        if (List.class.isAssignableFrom(fieldType))
            return LinkedList.class;
        if (Set.class.isAssignableFrom(fieldType))
            return LinkedHashSet.class;
        return NullType.class;
    }
}